#!/bin/bash
# this is the boot-service init script for the cloud resources
#
# openQRM Enterprise developed by openQRM Enterprise GmbH.
#
# All source code and content (c) Copyright 2014, openQRM Enterprise GmbH unless specifically noted otherwise.
#
# This source code is released under the GNU General Public License version 2, unless otherwise agreed with openQRM Enterprise GmbH.
# The latest version of this license can be found here: src/doc/LICENSE.txt
#
# By using this software, you acknowledge having read this license and agree to be bound thereby.
#
#           http://openqrm-enterprise.com
#
# Copyright 2014, openQRM Enterprise GmbH <info@openqrm-enterprise.com>
#

OPENQRM_SERVER_BASE_DIR=$(pushd $(dirname $0)/../../../../.. > /dev/null; echo $PWD; popd > /dev/null)
. $OPENQRM_SERVER_BASE_DIR/openqrm/include/openqrm-functions
. $OPENQRM_SERVER_BASE_DIR/openqrm/plugins/cloud/include/openqrm-plugin-cloud-functions
. $OPENQRM_RESOURCE_PARAMETER_FILE
OPENQRM_SERVER_IP=$resource_openqrmserver
NETWORK_CONF="/tmp/cloud-net.conf"
# define wget to use with https
if [ "$openqrm_web_protocol" == "https" ]; then
	WGET_NO_CERT_CHECK="--no-check-certificate"
fi


# do not start on the intitrd
if [ -f /etc/initrd-devices.conf ]; then
	exit 0
fi
# and do not run on the openQRM server itself
if [ -f $OPENQRM_SERVER_BASE_DIR/openqrm/etc/openqrm-server.conf ]; then
	exit 0
fi


function cloud_start() {
	echo "Starting the openQRM cloud-plugin"
	return 0
}


function cloud_stop() {
	echo "Stopping the openQRM cloud-plugin"
	return 0
}





case "$1" in
	start)
		cloud_start
		;;
	stop)
		cloud_stop
		;;
	restart)
		cloud_stop
		sleep 1
		cloud_start
		;;
	*)
		echo "Usage: $0 {start|stop|restart}"
		exit 1

esac
exit $?













